import time

from selenium import webdriver
from selenium.webdriver.common.by import By

driver=webdriver.Edge()
driver.get('https://music.163.com/')
driver.maximize_window()
time.sleep(2)
# 请登录
driver.find_element(By.XPATH,'/html/body/div[1]/div[1]/div/div[1]/a').click()
time.sleep(5)

# 选择其他方式登录
driver.find_element(By.XPATH,'/html/body/div[7]/div/div[2]/div/div/div[2]/div/div/div/a').click()
time.sleep(5)

# 同意协议
driver.find_element(By.ID,'j-official-terms').click()
time.sleep(2)
# qq登录
driver.find_element(By.XPATH,'/html/body/div[7]/div/div[2]/div/div/div[2]/div/div/div/div[1]/div[2]/ul/li[2]/a').click()
time.sleep(2)
# 多窗口切换
driver.switch_to.window(driver.window_handles[-1])



# 进入frame框架

driver.switch_to.frame(driver.find_element(By.ID,'ptlogin_iframe'))
time.sleep(5)

# 密码登录
driver.find_element(By.ID,'switcher_plogin').click()
time.sleep(15)
# 输入账号
driver.find_element(By.CLASS_NAME,'inputstyle').send_keys('1441688225')
time.sleep(2)
# 输入密码
driver.find_element(By.XPATH,'//*[@id="p"]').send_keys('xbw20120329XR')
time.sleep(2)

driver.find_element(By.ID,'login_button').click()
time.sleep(60)